<!-- 项目站址信息 -->
<template>
  <TCollapse title="项目站址信息">
    <iframe
      ref="siteInfoRef"
      :src="baseDetailsUrl"
      scrolling="no"
      width="100%"
      :height="basicHeight"
      frameborder="0"
    />
  </TCollapse>
</template>

<script>
import TCollapse from '@/components/basic/TCollapse.vue'
export default {
    name: 'ProjectSiteInfo',
    components: {
        TCollapse
    },
    props: {
        prjId: {
            type: String,
            default: '',
            required: true
        }
    },
    data() {
        return {
            basicHeight: ''
        }
    },
    computed: {
        baseDetailsUrl() {
            return `${process.env.VUE_APP_JUNNAN_IFRAME_URL}design/siteInfo?prjId=${this.prjId}`
        }
    },
    async created() {
        window.addEventListener('message', (event) => {
            const base_url = ''
            if (event.origin === base_url) {
                return
            }
            if (event.data.type === 'siteHeight') {
                if (this.$refs.siteInfoRef !== undefined) {
                    this.$refs.siteInfoRef.style.height = event.data.data + 'px'
                }
            }
        })
    }
}

</script>
<style lang="scss" scoped></style>
